//生成 据点模板

params["_marker", "_dir", "_arrVeh", "_arrUnit", ["_levelE", 2]];

private["_pos", "_init", "_end", "_group"];

_pos = getMarkerPos _marker;

//等待玩家进入
_init = false;
while{!_init} do
{
	sleep 20;
	//玩家进入范围创建
	{
		if((_x distance2D _pos) < 1500) exitWith
		{
			_init = true;
			//_____________________________清障碍物_____________________________
			[_pos, 3] call fn_cleanupTerrain;
			
			//_____________________________创建守卫_____________________________
			if(_levelE != 0) then
			{
				_group = createGroup west;
			}
			else
			{
				_group = createGroup civilian;
			};
			
			
			_group setBehaviour "SAFE";
			
			//_____________________________创建veh_____________________________
			private _arrVeh2 = [];
			//载具（或者是箱子、沙袋）最后创建
			{	
				private _type_x = (_x select 0);
				if(_type_x isKindof "AllVehicles"
				|| {_type_x find "Box" >= 0}
				|| {_type_x find "BagFence" >= 0}
				|| {_type_x find "SandbagBarricade" >= 0}
				|| {_type_x find "BagBunker" >= 0}) then
				{
					_arrVeh2 pushback _x;
				}
				else
				{
					if(count _x == 4) then
					{//只有4个参数，说明没有损坏值和油量
						_x pushback 0;
						_x pushback 1;
					};
					_x pushback _pos;
					_x pushback _group;
					_x call fn_createVeh;
				};
			
			}forEach _arrVeh;
			{	
				if(count _x == 4) then
				{//只有4个参数，说明没有损坏值和油量
					_x pushback 0;
					_x pushback 1;
				};
				_x pushback _pos;
				_x pushback _group;
				_x call fn_createVeh;
			}forEach _arrVeh2;
			
			//_____________________________创建固定单位_____________________________
			{	
				private _unit_china = [_x, _pos, 3, _group] call fn_createUnit;
			}forEach _arrUnit;
			
			//启用动态模拟
			_group enableDynamicSimulation true;
			
			//_____________________________不被清理标记_____________________________
			_group setVariable["no_cleanup", true];

		};
	}forEach AllPlayers;//所有玩家都能触发点
};
	
//等待玩家发现
_end = false;
while{!_end} do
{	
	{
	//加入距离限制判断
		if ((_x distance2D _pos) < 500) exitWith
		{
			_marker setMarkerShape "ICON";
			_marker setMarkerColor "ColorYellow";
			_marker setMarkerType "mil_box";
			_marker setMarkerSize [0.5, 0.5];
			_end = true;
		};
	}forEach (call fn_getPlayerRed);
	sleep 20;
};

	
